package org.weasel.views;

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.part.ViewPart;
import org.weasel.business.Developer;
import org.weasel.controllers.DeveloperEditViewController;

public class DeveloperEditView extends ViewPart {

	public static final String ID = "org.weasel.views.DeveloperEditView"; // TODO Needs to be whatever is mentioned in plugin.xml

	private DeveloperEditViewController controller;
	private Composite top = null;

	private Label label = null;

	private Text txtName = null;

	private Text txtEmail = null;

	private Text txtPosition = null;

	private Label label1 = null;

	private Label label2 = null;

	@Override
	public void createPartControl(Composite parent) {
		// TODO Auto-generated method stub
		top = new Composite(parent, SWT.NONE);
		top.setLayout(null);
		label = new Label(top, SWT.NONE);
		label.setBounds(new Rectangle(15, 23, 106, 16));
		label.setText("Name:");
		txtName = new Text(top, SWT.BORDER);
		txtName.setBounds(new Rectangle(135, 15, 211, 31));
		txtName.addFocusListener(new org.eclipse.swt.events.FocusAdapter() {
			public void focusLost(org.eclipse.swt.events.FocusEvent e) {
				controller.setDeveloperName(txtName.getText());
			}
		});
		txtEmail = new Text(top, SWT.BORDER);
		txtEmail.setBounds(new Rectangle(135, 60, 211, 31));
		txtEmail.addFocusListener(new org.eclipse.swt.events.FocusAdapter() {
			public void focusLost(org.eclipse.swt.events.FocusEvent e) {
				controller.setDeveloperEmail(txtEmail.getText());
			}
		});
		txtPosition = new Text(top, SWT.BORDER);
		txtPosition.setBounds(new Rectangle(135, 105, 211, 31));
		txtPosition.addFocusListener(new org.eclipse.swt.events.FocusAdapter() {
			public void focusLost(org.eclipse.swt.events.FocusEvent e) {
				controller.setDeveloperPosition(txtPosition.getText());
			}
		});
		label1 = new Label(top, SWT.NONE);
		label1.setBounds(new Rectangle(15, 66, 106, 16));
		label1.setText("Email:");
		label2 = new Label(top, SWT.NONE);
		label2.setBounds(new Rectangle(15, 113, 103, 17));
		label2.setText("Position:");
		controller = DeveloperEditViewController.instance();
	}

	public void showDeveloperInformation(Developer developer){
		txtName.setText(developer.getName());
		txtEmail.setText(developer.getEmail());
		txtPosition.setText(developer.getPosition());
	}
	
	@Override
	public void setFocus() {
		// TODO Auto-generated method stub

	}

}  //  @jve:decl-index=0:visual-constraint="10,10,398,202"
